import time
from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait

# 1.打开浏览器
driver = webdriver.Chrome(executable_path='../01/chromedriver.exe')
# driver = webdriver.Chrome() #创建浏览器对象
# 放大浏览器页面
driver.maximize_window()
# 2.输入访问地址（URL）
driver.get("http://121.43.169.97:8848/pageA.html")

# 1). 填写注册信息
driver.find_element_by_id("userA").send_keys("admin")
# 2). 截图保存
driver.get_screenshot_as_file("../img/img01.png")

# 动态获取文件名称，使用时间戳
# driver.get_screenshot_as_file("../img/%s.png" % time.strftime("%Y_%m_%d_%H_%M_%S"))
driver.get_screenshot_as_file("../img/{}.png".format(time.strftime("%Y_%m_%d_%H_%M_%S")))


# 可选：关闭浏览器（根据需求添加）
# driver.quit()